var map = null, clickStatus = false;
//var clickButStatus = "normal";//点击筛选按钮得到的状态
var BaiDuMap = {
    /**
     * 初始化地图
     */
    map: function (mapId, obj) {
        map = new BMap.Map(mapId, obj);
    },
    /**
     * 定义点
     * longitude 经度
     * latitude 纬度
     */
    point: function (longitude, latitude) {
        var point = new BMap.Point(longitude, latitude);
        return point;
    },
    /**
     * 创建标注
     * no 编号(唯一)
     * deviceName 设备名称
     * position 安装位置
     */
    addMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4,fireCount) {
    	
//    	$.ajax({
//    		url:'http://localhost:9090/alarm/species/device/count?beginTime=2018-01-01%2000:00:00&endTime=2018-07-04%2023:59:59&alarmTypeCode=001&devCode='+no,
//    		
//    	});
            	
        // 拼接html字符串
        var sContent = "<div style='margin-top: -20px;'>"
        //sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div><span style='position:absolute;right:20px;'><span style='display: inline-block;background: green;width: 27px;height: 12px;'></span><span style='font-weight: normal;font-size: 14px;'>一般火险等级</span></span></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
        if(fireCount == 1){
        	sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div><span style='position:absolute;right:20px;'><span style='display: inline-block;background: #ffc64b;width: 27px;height: 14px;'></span><span style='font-weight: normal;font-size: 16px;color:#ffc64b;'> 较大火险场所</span></span></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
            
        }else if(fireCount == 2){
        	sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div><span style='position:absolute;right:20px;'><span style='display: inline-block;background: #ff5151;width: 27px;height: 14px;'></span><span style='font-weight: normal;font-size: 16px;color:#ff5151;'> 高危火险场所</span></span></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
            
        }else{
        	sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div><span style='position:absolute;right:20px;'><span style='display: inline-block;background: green;width: 27px;height: 14px;'></span><span style='font-weight: normal;font-size: 16px;color:green;'> 一般火险场所</span></span></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
            
        }
        
        sContent += "<div style='padding: 4px;color: #666;min-width: 120px;border-bottom:1px solid #eee;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
        sContent += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
        sContent += ""
        if ((linkMain1 != null) && (linkMain1.length != 0)) {
            sContent += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
        }
        if ((linkMain2 != null) && (linkMain2.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
        }
        if ((linkMain3 != null) && (linkMain3.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
        }
        if ((linkMain4 != null) && (linkMain4.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
        }
        sContent += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td></tr>";
        sContent += "</tbody></table></div></div>";

        // 自定义覆盖物
        function ComplexCustomOverlay(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function (map) {
            this._map = map;
            var div = this._div = document.createElement("div");
            div.className = "active-alarm-pointer";
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            var activeStyleDiv = "<div class='dot'></div>" +
                "<div class='pulse pulseTop22'></div>" +
                "<div class='pulse1 pulseTop22'></div>";
            div.innerHTML = activeStyleDiv;
//		        setTop(isTop: true)

            div.onmouseover = function () {
                //
            }

            div.onmouseout = function () {
                //
            }
            map.getPanes().labelPane.appendChild(div);
            div.parentElement.style.zIndex = div.style.zIndex + 1;//Let ripple be below the icon
            return div;
        }
        ComplexCustomOverlay.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - 40 - 8 + 'px';
            this._div.style.top = pixel.y - 40 + 20 + 'px';
        }

        ComplexCustomOverlay.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
            this._div['on' + event] = fun;
        }

        if (status == 'fire') {

            var myIcon = new BMap.Icon("map/images/smoke-red.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
            var marker2 = new ComplexCustomOverlay(point);
            marker2.no = no;
            marker2.status = status;
            map.addOverlay(marker2);
//				设置火警图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
            //火警光圈向上移动24px
            //$(".active-alarm-pointer").parent().css("top", "-30px");
        } else if (status == 'lowpower') {
            var myIcon = new BMap.Icon("map/images/smoke-yellow.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
        } else if (status == 'malfunction') {
//				,{anchor: new BMap.Size(30, 24),infoWindowAnchor: new BMap.Size(30, 20)},offset: new BMap.Size(0, -24)
            var myIcon = new BMap.Icon("map/images/smoke-grey.png", new BMap.Size(40, 48));//,{anchor: new BMap.Size(0, -24)}
            marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});


        } else if (status == 'normal') {
            var myIcon = new BMap.Icon("map/images/smoke-blue.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
        } else {
            var marker = new BMap.Marker(point);
        }

        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
        var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
//			 markerNormalmHide()
        //5、 为自定义覆盖物添加点击事件
        marker.addEventListener('click', function (e) {

//			        地图信息框显示
            $('.BMap_pop').parent().show();
            $(".BMap_shadow").parent().show();
            map.openInfoWindow(infoWindow, point);
            //控制信息窗口向上移动 ,offset: new BMap.Size(0, -24)
            $(".BMap_pop").parent().css("top", "-24px")
            $(".BMap_shadow").parent().css("top", "-24px")

            //hide_show();
        });

//		    覆盖物显示
        function showOver() {
            marker.show();
        }

//			覆盖物隐藏
        function hideOver() {
            marker.hide();
        }

        $(".slimScrollDiv").on('click', '.li_device', function () {
            hideOver();
        });
        //显示报警光圈
        function pulseShow() {
            $(".active-alarm-pointer .pulse").show();
            $(".active-alarm-pointer .pulse1").show();
        }

        //隐藏报警光圈
        function pulseHide() {
            $(".active-alarm-pointer .pulse").hide();
            $(".active-alarm-pointer .pulse1").hide();
        }

        //定位重点关注的设备
        $(".object-ul").on("click", "li", function () {
            var devicecode = $(this).attr("devicecode");
            hideOver();
            if (devicecode == no) {
                showOver();
//                pulseShow();
                pulseHide();
                if (status == "fire") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    //$(".active-alarm-pointer").parent().css("top", "-30px")
                } else {
                    pulseHide();
                }
            }
        });
        //历史消息焦点
        $(".historyList").on('click', '.li_device', function () {
            var devicecode = $(this).attr("devicecode");
            hideOver();
            if (devicecode == no) {
                showOver();
//                pulseShow();
                pulseHide();
                if (status == "fire") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    //$(".active-alarm-pointer").parent().css("top", "-30px")
                } else {
                    pulseHide();
                }
            }
        });
        //点击搜索列表显示单个点位-------TODO--------
//        $(".searchList").on("click",'li',function (){
//        	var devicecode = $(this).attr('devicecode');
//            if (devicecode == no) {
//            	showOver();
//            }
//        });
//        $(".searchBox .input-group-btn .search-btn").on("click",function (){
//        	var devicecode = $(this).attr('devicecode');
//	          if (devicecode == no) {
//	          	showOver();
//	        }
//        });
//			筛选报警状态
        $(".smokeAlarmMenu").on("click", function () {
            //clickButStatus = "fire";
            showOver();
            if (!(status == "fire")) {
                map.closeInfoWindow();
//            		先隐藏地图上的报警状态图标，再显示
                hideOver();
                pulseShow();
//            		历史消息内容切换
//                $("#control-sidebar-theme-demo-options-tab").addClass("active");
//                $("#control-sidebar-home-tab").removeClass("active");
//                $("#control-sidebar-settings-tab").removeClass("active");
//                $(".alarmhistorybtn").addClass("active");
//                $(".faulthistorybtn").removeClass("active");
//                $(".lowhistorybtn").removeClass("active");
            } else {

            }
            return false;
        });

        $(".faultMenu").on("click", function () {
            //clickButStatus = "malfunction";
            showOver();
            if (!(status == "malfunction")) {
                map.closeInfoWindow();
                hideOver();
                pulseHide();
//            		历史消息内容切换
//                $("#control-sidebar-home-tab").addClass("active");
//                $("#control-sidebar-settings-tab").removeClass("active");
//                $("#control-sidebar-theme-demo-options-tab").removeClass("active");
//                $(".alarmhistorybtn").removeClass("active");
//                $(".faulthistorybtn").addClass("active");
//                $(".lowhistorybtn").removeClass("active");
            } else {
//              		 
            }
            return false;
        });
        $(".lowPowerMenu").on("click", function () {
            //clickButStatus = "lowpower";
            showOver();
            if (!(status == "lowpower")) {
                map.closeInfoWindow();
                BaiDuMap.deletePointStatus()
                hideOver();
                pulseHide();
//            		历史消息内容切换
//                $("#control-sidebar-settings-tab").addClass("active");
//                $("#control-sidebar-home-tab").removeClass("active");
//                $("#control-sidebar-theme-demo-options-tab").removeClass("active");
//                $(".alarmhistorybtn").removeClass("active");
//                $(".faulthistorybtn").removeClass("active");
//                $(".lowhistorybtn").addClass("active");

            } else {

            }
            return false;
        });
        $(".smokeSum").on("click", function () {
            showDropdown();//BaiDuMap.
            showOver();
            return false;
        });
//        $(".bottombar-item").click()
//        $("#smokeDetectorBtn").click(function (){
//    		hideOver();
////        	if(!$(this).hasClass("selected")){
////        		if(status=="normal"){
////        			showOver();
////        		}else{
////        			hideOver();
////        		}
////        	}else{
////        		hideOver();
////        	}
//        })
        

    },//addMarker end

//		摄像头
    cameraAddMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, cameraUrl, loginName, loginPassword) {

        // 自定义覆盖物
        function ComplexCustomOverlay(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function (map) {
            this._map = map;
            var div = this._div = document.createElement("div");
            div.className = "active-alarm-pointer";
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            map.getPanes().labelPane.appendChild(div);
            div.parentElement.style.zIndex = div.style.zIndex + 1;//Let ripple be below the icon
            return div;
        }
        ComplexCustomOverlay.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - 40 - 8 + 'px';
            this._div.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
            this._div['on' + event] = fun;
        }

        if (status == 'cameraNormal') {
            //摄像头——正常
            var myIcon = new BMap.Icon("map/images/camera-blue.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//				设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else {
            var marker = new BMap.Marker(point);
        }

        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
//			 markerNormalmHide()
        //5、 为自定义覆盖物添加点击事件

//	        $("#videoIfm").contents().find("#userAddress").val(cameraUrl);

        marker.addEventListener('click', function () {
//		        if(cameraUrl){
            cameraPlayFunc();
            $("#outgoingDiv").html('<iframe cameraUrl="' + cameraUrl + '" loginName="' + loginName + '" loginPassword="' + loginPassword + '" id="videoIfm" name="videoIfm" style="height:100%;width:100%;" frameborder="0";scrolling="no"; frameborder="0" src="/video"></iframe>');

            $("#cameraVideoModal .modal-title span").html(position);

//		        }
        });
//		    覆盖物显示
        function showOver() {
            marker.show();
        }

//			覆盖物隐藏
        function hideOver() {
            marker.hide();
        }


    },//addMarker end
// 窨井盖
    manholeCoverAddMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {

        // 拼接html字符串border-bottom:1px solid #eee;
        var sContent = "<div style='margin-top: -20px;'>"
        sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
        sContent += "<div style='padding: 4px;color: #666;min-width: 120px;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
        sContent += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
        sContent += ""
        if ((linkMain1 != null) && (linkMain1.length != 0)) {
            sContent += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
        }
        if ((linkMain2 != null) && (linkMain2.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
        }
        if ((linkMain3 != null) && (linkMain3.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
        }
        if ((linkMain4 != null) && (linkMain4.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
        }
        sContent += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td><td><button id='coverDetailsBtn' class='btn btn-primary btn-xs' data-toggle='modal' type='button'>设备详情</button></td></tr>";
        sContent += "</tbody></table></div></div>";

        var sContent1 = "<div style='margin-top: -20px;'>"
            sContent1 += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
            sContent1 += "<div style='padding: 4px;color: #666;min-width: 120px;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
            sContent1 += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
            sContent1 += ""
            if ((linkMain1 != null) && (linkMain1.length != 0)) {
                sContent1 += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
            }
            if ((linkMain2 != null) && (linkMain2.length != 0)) {
                sContent1 += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
            }
            if ((linkMain3 != null) && (linkMain3.length != 0)) {
                sContent1 += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
            }
            if ((linkMain4 != null) && (linkMain4.length != 0)) {
                sContent1 += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
            }
            sContent1 += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td></tr>";
            sContent1 += "<tr class='coversContent1Hide' style='display:none;'><td class='tit'>维保单位:</td><td colspan='2'>罗万</td></tr>";
            sContent1 += "<tr class='coversContent1Hide' style='display:none;'><td class='tit'>维保人:</td><td colspan='2'>张工</td></tr>";
            sContent1 += "<tr class='coversContent1Hide' style='display:none;'><td class='tit'>上次维保时间:</td><td colspan='2'>2018-4-10 9:00</td></tr>";

            sContent1 += "</tbody></table><tr class='coversContent1Hide' style='display:none;'><img style='margin:3px 0;width:110px;height:80px;margin-right:10px;border:3px solid #6e6e6e;' src='/icons/cover-before.png'><img style='margin:3px 0;width:110px;height:80px;margin-right:10px;border:3px solid #6e6e6e;' src='/icons/cover-after.png'><img style='margin:3px 0;width:110px;height:80px;border:3px solid #6e6e6e;' src='/icons/cover-gps.png'></tr><p style='float:left;margin-left:30px;'>安装前</p><p style='float:left;margin-left:77px;'>安装后</p><p style='float:left;margin-left:86px;'>定位</p></div></div>";
//<button id='coverDetailsBtn' style='margin-left:290px;' class='btn btn-primary btn-xs' data-toggle='modal' type='button'>设备详情</button>
            
        //<div class='coverDetailsList' style='width:100px;height:100px;'></div>
        // 自定义覆盖物
        function ComplexCustomOverlay(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function (map) {
            this._map = map;
            var div = this._div = document.createElement("div");
            div.className = "active-alarm-pointer";
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            var activeStyleDiv = "<div class='dot'></div>" +
                "<div class='pulse pulseTop22'></div>" +
                "<div class='pulse1 pulseTop22'></div>";
            div.innerHTML = activeStyleDiv;
//		        setTop(isTop: true)

            div.onmouseover = function () {
                //
            }

            div.onmouseout = function () {
                //
            }
            map.getPanes().labelPane.appendChild(div);
            div.parentElement.style.zIndex = div.style.zIndex + 1;//Let ripple be below the icon
            return div;
        }

        ComplexCustomOverlay.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - 40 - 8 + 'px';
            this._div.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
            this._div['on' + event] = fun;
        }
        if (status == 'manholeCoverEctopic') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/cover-red.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            var marker2 = new ComplexCustomOverlay(point);
            marker2.no = no;
            marker2.status = status;
            map.addOverlay(marker2);
//				设置火警图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
            //火警光圈向上移动24px
            //$(".active-alarm-pointer").parent().css("top", "-20px")
        } else if (status == 'manholeCoverFault') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/cover-grey.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'manholeCoverLow') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/cover-yellow.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'manholeCoverNormal') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/cover-blue.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        }
        else {
            var marker = new BMap.Marker(point);
        }

        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
        var infoWindow = new BMap.InfoWindow(sContent);
        var infoWindow1 = new BMap.InfoWindow(sContent1);
        
        // 创建信息窗口对象
//					 markerNormalmHide()
        //5、 为自定义覆盖物添加点击事件
        marker.addEventListener('click', function () {
            map.openInfoWindow(infoWindow, point);

            //控制信息窗口向上移动
            $(".BMap_pop").parent().css("top", "-24px")
            $(".BMap_shadow").parent().css("top", "-24px")
            if (status == 'manholeCoverNormal') {
            }
            $("body #coverDetailsBtn").on("click", coverDetailsFunc());
            
        });
        function coverDetailsFunc(){
        	$("#coverDetailsBtn").click(function (){
        		map.closeInfoWindow();
        		map.openInfoWindow(infoWindow1, point);
        		$(".coversContent1Hide").show();
//        		$(".coverDetailsList").hide();
        	})
        	
        }
        //显示报警光圈
        function pulseShow() {
            $(".active-alarm-pointer .pulse").show();
            $(".active-alarm-pointer .pulse1").show();
        }

        //隐藏报警光圈
        function pulseHide() {
            $(".active-alarm-pointer .pulse").hide();
            $(".active-alarm-pointer .pulse1").hide();
        }

//				    覆盖物显示
        function showOver() {
            marker.show();
        }

//					覆盖物隐藏
        function hideOver() {
            marker.hide();
        }

        //定位重点关注的设备
        $(".object-ul").on("click", "li", function () {
            var devicecode = $(this).attr("devicecode");
            hideOver();
            if (devicecode == no) {
                showOver();
//                pulseShow();
                pulseHide();
                if (status == "manholeCoverEctopic") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    //$(".active-alarm-pointer").parent().css("top", "-20px")
                } else {
                    pulseHide();
                }
            }
        });
        //历史消息焦点
        $(".historyList").on('click', '.li_device', function () {
            var devicecode = $(this).attr("devicecode");
            hideOver();
            if (devicecode == no) {
                showOver();
//                pulseShow();
                pulseHide();
                if (status == "manholeCoverEctopic") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    //$(".active-alarm-pointer").parent().css("top", "-20px")
                } else {
                    pulseHide();
                }
            }
        });
//					筛选状态
        $(".manholeCover-menu-ectopic").on("click", function () {
            showOver();
            pulseShow();
            if (!(status == "manholeCoverEctopic")) {
                map.closeInfoWindow();
//		            		先隐藏地图上的报警状态图标，再显示
                hideOver();
            } else {

            }
            return false;
        });

        $(".manholeCover-menu-fault").on("click", function () {
            showOver();
            if (!(status == "manholeCoverFault")) {
                map.closeInfoWindow();
                hideOver();
                pulseHide();
            } else {
//		              		 
            }
            return false;
        });
        $(".manholeCover-menu-low").on("click", function () {
            showOver();
            if (!(status == "manholeCoverLow")) {
                map.closeInfoWindow();
                hideOver();
                pulseHide();
            } else {
//		              		 
            }
            return false;
        });
        $(".manholeCover-menu-normal").on("click", function () {
            showOver();
            pulseShow();
            return false;
        });

    },//addMarker end

    // 温湿度,temperatureNum,humidityNum
    humitureAddMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, temperatureNum, humidityNum) {

        // 拼接html字符串
        var sContent = "<div style='margin-top: -20px;'>"
        sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
        sContent += "<div style='padding: 4px;color: #666;min-width: 120px;border-bottom:1px solid #eee;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
        sContent += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
        sContent += ""
        if ((linkMain1 != null) && (linkMain1.length != 0)) {
            sContent += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
        }
        if ((linkMain2 != null) && (linkMain2.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
        }
        if ((linkMain3 != null) && (linkMain3.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
        }
        if ((linkMain4 != null) && (linkMain4.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
        }
        var humitureDate3 = moment().add('days',0).format('DD');
        var humitureDate2 = moment().add('days',-1).format('DD');
        var humitureDate1 = moment().add('days',-2).format('DD');
        sContent += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td></tr>";
        sContent += "</tbody></table></div></div><div style='padding:6px 0'><div style='display: inline-block;height: 30px;line-height: 30px;float:left;'><strong style='font-size: 14px;'><span class='humitureChartDate'>"+humitureDate3+"</span>日温湿度折现统计图</strong></div><div class='btn-group' style='margin:6px 10px 0 186px;'><button type='button' class='btn btn-info btn-xs humitureDate1'>"+humitureDate1+"日</button><button type='button' class='btn btn-info btn-xs humitureDate2'>"+humitureDate2+"日</button><button type='button' class='btn btn-info btn-xs humitureDate3'>"+humitureDate3+"日</button></div><button class='btn btn-primary btn-xs' data-toggle='modal' id='humitureDeviceHistory1' type='button' style='margin-top:6px;'>历史</button></div><div style='height:300px;' id='myChart1'></div><div class='humitureChartNone' style='width:500px;height:300px;background:url(/icons/humiture-chart-none-big.png) no-repeat;'></div>";
//<div style='margin-top:5px;'><span style='display: inline-block;text-align: center;width: 30px;height: 30px;background-color:red;color:#fff;line-height: 30px;cursor:pointer;'>月</span><span style='display: inline-block;text-align: center;width: 30px;height: 30px;background-color:blue;color:#fff;line-height: 30px;cursor:pointer;'>周</span><span style='display: inline-block;text-align: center;width: 30px;height: 30px;background-color:green;color:#fff;line-height: 30px;cursor:pointer;'>日</span></div>
//        <div style='display: inline-block;height: 30px;line-height: 30px;'><strong style='font-size: 14px;'>30天内温湿度变化</strong></div>
//         onclick='{$('#humitureHisSearchModal').modal('show');}'

        // 自定义覆盖物
        function ComplexCustomOverlay2(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay2.prototype = new BMap.Overlay();
        ComplexCustomOverlay2.prototype.initialize = function (map) {
            this._map = map;
            var div1 = this._div1 = document.createElement("div");
            div1.className = "active-alarm-pointer0";
            div1.style.position = "absolute";
            div1.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            var activeStyleDiv = "<div class='dot'></div>" +
                "<div class='pulse0 pulseTop22'></div>" +
                "<div class='pulse10 pulseTop22'></div><div class='humitureNumShow1' style='position:relative;'><div class='humitureNum humitureNumBGC'>" + temperatureNum + "<span></span>" + humidityNum + "</div></div>";
            //
            div1.innerHTML = activeStyleDiv;
            map.getPanes().labelPane.appendChild(div1);
            div1.parentElement.style.zIndex = div1.style.zIndex + 1;//Let ripple be below the icon
            return div1;
        }
        ComplexCustomOverlay2.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div1.style.left = pixel.x - 40 - 8 + 'px';
            this._div1.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay2.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay2.prototype.addEventListener = function (event, fun) {
            this._div1['on' + event] = fun;
        }
//        --------------------
        // 自定义覆盖物
        function ComplexCustomOverlay1(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay1.prototype = new BMap.Overlay();
        ComplexCustomOverlay1.prototype.initialize = function (map) {
            this._map = map;
            var humiturediv = this._div1 = document.createElement("div");
            humiturediv.style.position = "absolute";
            humiturediv.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            var humitureNumDiv = "<div class='humitureNumShow2'><div class='humitureNum'>" + temperatureNum + "<span></span>" + humidityNum + "</div></div>";
            humiturediv.innerHTML = humitureNumDiv;
//    		        setTop(isTop: true)

            map.getPanes().labelPane.appendChild(humiturediv);
            humiturediv.parentElement.style.zIndex = humiturediv.style.zIndex + 1;

            return humiturediv;
        }

        ComplexCustomOverlay1.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div1.style.left = pixel.x - 40 - 8 + 'px';
            this._div1.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay1.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay1.prototype.addEventListener = function (event, fun) {
            this._div1['on' + event] = fun;
        }
//        ----------------
        if (status == 'humitureAlarm') {
            //温湿度——报警

            var myIcon = new BMap.Icon("map/images/temp-hum-red.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//    						设置图标在上层显示
            var marker2 = new ComplexCustomOverlay2(point);
            marker2.no = no;
            marker2.status = status;
            map.addOverlay(marker2);
//    				设置火警图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
            //火警光圈向上移动24px
        } else if (status == 'humitureFault') {
            //温湿度——故障

            var myIcon = new BMap.Icon("map/images/temp-hum-grey.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//			设置图标在上层显示
//            var marker3 = new ComplexCustomOverlay1(point);
//            marker3.no = no;
//            marker3.status = status;
//            map.addOverlay(marker3);
//    						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'humitureLow') {
            //温湿度——低电

            var myIcon = new BMap.Icon("map/images/cover-yellow.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//    						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'humitureNormal') {
            //温湿度——正常

            var myIcon = new BMap.Icon("map/images/temp-hum-blue.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});

//			设置图标在上层显示
            var marker3 = new ComplexCustomOverlay1(point);
            marker3.no = no;
            marker3.status = status;
            map.addOverlay(marker3);
//    				设置火警图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
//            var humitureNumShow2Top = $(".humitureNumShow2").parent().css("top")
//            $(".humitureNumShow2").parent().css("top",humitureNumShow2Top+19+"px")
        }
        else {
            var marker = new BMap.Marker(point);
        }

//        $(".active-alarm-pointer").parent().css("top", "0px")
        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
        var infoWindow = new BMap.InfoWindow(sContent, {width: 500});

        //5、 为自定义覆盖物添加点击事件
        var timeoutflag = null;
        marker.addEventListener('click', function () {
        	
            if (timeoutflag != null) {
                clearTimeout(timeoutflag);
                timeoutflag = null;
            } else {
                timeoutflag = setTimeout(function () {
                    map.openInfoWindow(infoWindow, point);
                    //控制信息窗口向上移动
                    $(".BMap_pop").parent().css("top", "-24px")
                    $(".BMap_shadow").parent().css("top", "-24px")
                    var data1 = [];
                    var data2 = [];
                    var data3 = [];
                    var humitureChartLen = false;
                   var humidity="";
                   var temperature1="";
         	       var beginTime = moment().add('days',0).format('YYYY-MM-DD')+" 00:00:00";
         	       var endTime = moment().add('days',0).format('YYYY-MM-DD')+" 23:59:59";
                   $("body #humitureDeviceHistory1").off().on("click",humitureHistoryFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime));
                   humitureChartFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime);

                   
                    timeoutflag = null;
                },0)

            }
        });
        function humitureChartFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime){
            $.ajax({
                type: "GET",
                url: "/deviceStatusHistory/listByTimeAndCode/sorting?beginTime="+beginTime+"&endTime="+endTime+"&devCode=" + no,
                async: false, //同步执行
                dataType: "json", //返回数据形式为json result.data.length
                success: function (result) {
                    if (result.status == 200) {
                    	if(result.data.length){
                    		$(".humitureChartNone").hide();
                    		$("#myChart1").show();
                        	//$("#myChart1").css("height","300px");
                        	humitureChartLen = true;
                    	}else{
                    		$("#myChart1").hide();
                    		$(".humitureChartNone").show();
                    		humitureChartLen = true;
                    		//data1=[0,10,20,30,40];
                    		//data2=[0,10,20,30,40];
                    		//data3=["00:00","23:23"];
                        	//$("#myChart1").hide();
                        	//winTip.alert("暂无数据");
                    }
                    for (var i = 0; i < result.data.length; i++) {
                        	temperature1 = result.data[i][0] ? result.data[i][0] : "";
                        	humidity = result.data[i][1] ? result.data[i][1] : "";
                            data1.push(temperature1);
                            data2.push(humidity);
                            data3.push(moment(result.data[i][2]).format('HH:mm'))
                        }
                    }
                },
                error: function (errorMsg) {
                    winTip.alert("图表请求数据失败!");
                    myChart.hideLoading();
                }
            });
            
            /*         		$(".alarmhistorybtn i").removeClass("fire-alarm-tab").addClass("cover-alarm-tab");
             deviceTypeId = "007";
             alarmTypeCode = "061";
             sevenAlarmSum (alarmTypeCode,deviceTypeId,alarmDateArr);
             alarmBar(alarmDateArr); */
            //温湿度数据统计
            //var timer1=window.setTimeout(setAnyChartFun(),1000);
           if(humitureChartLen){
        	   setAnyChartFun(data1,data2,data3);
           }
        }

        function humitureHistoryFunc(){
      	   $(".humitureDate1").click(function (){
     		   $(".humitureChartDate").text(moment().add('days',-2).format('DD'));
                var data1 = [];
                var data2 = [];
                var data3 = [];
                var humitureChartLen = false;
               var humidity="";
               var temperature1="";
      	       var beginTime = moment().add('days',-2).format('YYYY-MM-DD')+" 00:00:00";
      	       var endTime = moment().add('days',-2).format('YYYY-MM-DD')+" 23:59:59";
                humitureChartFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime);
     	   });
     	   $(".humitureDate2").click(function (){
     		   $(".humitureChartDate").text(moment().add('days',-1).format('DD'));
                var data1 = [];
                var data2 = [];
                var data3 = [];
                var humitureChartLen = false;
               var humidity="";
               var temperature1="";
      	       var beginTime = moment().add('days',-1).format('YYYY-MM-DD')+" 00:00:00";
      	       var endTime = moment().add('days',-1).format('YYYY-MM-DD')+" 23:59:59";
                humitureChartFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime);
     	   });
     	   $(".humitureDate3").click(function (){
     		   $(".humitureChartDate").text(moment().add('days',0).format('DD'));
                var data1 = [];
                var data2 = [];
                var data3 = [];
                var humitureChartLen = false;
               var humidity="";
               var temperature1="";
      	       var beginTime = moment().add('days',0).format('YYYY-MM-DD')+" 00:00:00";
      	       var endTime = moment().add('days',0).format('YYYY-MM-DD')+" 23:59:59";
                humitureChartFunc(data1,data2,data3,humitureChartLen,humidity,temperature1,beginTime,endTime);
     	   });
            var flag=true;
        	$("#humitureDeviceHistory1").click(function (){
        		$("#humitureHisSearchModal").modal('show');
                if(flag){
                    var startTime = $(".searchStartData input").val() + " 00:00:00";
                    var endTime = $(".searchEndData input").val() + " 23:59:59";
                    $.ajax({
                        url: "/alarm/data/history/list?beginTime="+startTime+"&endTime="+endTime+"&deviceTypeId="+devTypeId,
                        type: 'GET',
                        async:false,
                        success: function (result) {
                          if (result.status == 200) {
            					//请求成功去掉loading状态 
            				$(".humitureHisSearchTitle tbody").html('');
            				if(!result.data.length){
            					winTip.alert("暂无数据!");
            				}else{
            					
            					$("#humitureHisSearchModal .resultSum span").text(result.data.length);
            	                  for(var i=0;i<result.data.length;i++){
            	                    var data = result.data[i];
            	                    var alarmStatus;
            	                    if(data.alarmType.alarmCode == '061'){
            	                      alarmStatus = "温湿度报警";
            	                    }else if(data.alarmType.alarmCode == '062'){
            	                      alarmStatus = "温湿度故障";
            	                    }
            	                    var beginTime = moment(data.beginTime).format('YYYY-MM-DD HH:mm:ss')
            	                    var endTime = data.endTime;
            	                    if(endTime){
            	                        endTime = moment(endTime).format('YYYY-MM-DD HH:mm:ss')
            	                    }else{
            	                      endTime = "";
            	                    }
            	                    var disposeStatus = data.disposeStatus?data.disposeStatus:"";
            	                    if(disposeStatus == 1){
            	                    	disposeStatusStr = "已处理";
            	                    }else if(disposeStatus == 2){
            	                    	disposeStatusStr = "未处理";
            	                    }else{
            	                    	disposeStatusStr = "";
            	                    }
            	                    var disposePeople = data.disposePeople?data.disposePeople:"";
            	                      $(".humitureHisSearchTitle tbody").prepend('<tr><td>'+data.device.deviceName+'</td><td>'+data.address+'</td><td>'+alarmStatus+'</td><td>'+beginTime+'</td><td>'+endTime+'</td><td>'+disposeStatusStr+'</td><td>'+disposePeople+'</td><td>'+data.device.devCode+'</td></tr>');
            	                  }
            				}
                          
                          } else {
                        	  winTip.alert(result.message);
                          }
                        }

                      }); 
                    flag = false;
                }
        	});
        	
        }

        //显示报警光圈
        function pulseShow() {
            $(".active-alarm-pointer0 .pulse0").show();
            $(".active-alarm-pointer0 .pulse10").show();
        }

        //隐藏报警光圈
        function pulseHide() {
            $(".active-alarm-pointer0 .pulse0").hide();
            $(".active-alarm-pointer0 .pulse10").hide();
        }

//    				    覆盖物显示
        function showOver() {
            marker.show();
        }

//    					覆盖物隐藏
        function hideOver() {
            marker.hide();
        }

        //定位重点关注的设备
        $(".object-ul").on("click", "li", function () {
            var devicecode = $(this).attr("devicecode");
            hideOver();
           // if (devicecode == no) {
                showOver();
//                    pulseShow();
                pulseHide();
                if (status == "humitureFault") {
                    $(".humitureNumShow1").hide();
                    $(".humitureNumShow2").hide();
                } else if (status == "humitureNormal") {
//                    var myIcon = new BMap.Icon("map/images/temp-hum-blue.png", new BMap.Size(40, 48));
//                    var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//
////        			设置图标在上层显示
//                    var marker3 = new ComplexCustomOverlay1(point);
//                    marker3.no = no;
//                    marker3.status = status;
//                    map.addOverlay(marker3);
////            				设置火警图标在上层显示
//                    marker.setTop(true);
//                    marker.setZIndex(100);
                    $(".humitureNumShow1").show();
                    $(".humitureNumShow2").show();
                }
                if (status == "humitureAlarm") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay1(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    $(".humitureNumShow1").show();
                    $(".humitureNumShow2").show();
                    //$(".active-alarm-pointer0").parent().css("top", "-30px");
                } else {
                    pulseHide();
                }
            //}
        });
        //历史消息焦点
        $(".historyList").on('click', '.li_device', function () {
//            var devicecode = $(this).attr("devicecode");
//            hideOver();
//            //if (devicecode == no) {
//                showOver();
////                    pulseShow();
//                pulseHide();
//                if (status == "humitureFault") {
//                    $(".humitureNumShow1").hide();
//                    $(".humitureNumShow2").hide();
//                } else if (status == "humitureNormal") {
//                    $(".humitureNumShow1").show();
//                    $(".humitureNumShow2").hide();
//                }
//                if (status == "humitureAlarm") {
//                    //pulseShow()
//                    var marker2 = new ComplexCustomOverlay1(point);
//                    marker2.no = no;
//                    marker2.status = status;
//                    map.addOverlay(marker2);
//                    //				设置火警图标在上层显示
//                    marker.setTop(true);
//                    marker.setZIndex(100);
//                    //火警光圈向上移动24px
//                    $(".humitureNumShow1").show();
//                    $(".humitureNumShow2").hide();
//                } else {
//                    pulseHide();
//                }
//           // }
            var devicecode = $(this).attr("devicecode");
            hideOver();
           // if (devicecode == no) {
                showOver();
//                    pulseShow();
                pulseHide();
                if (status == "humitureFault") {
                    $(".humitureNumShow1").hide();
                    $(".humitureNumShow2").hide();
                } else if (status == "humitureNormal") {
                	console.log(111)
                    $(".humitureNumShow1").show();
                    $(".humitureNumShow2").show();
                }
                if (status == "humitureAlarm") {
                    //pulseShow()
                    var marker2 = new ComplexCustomOverlay1(point);
                    marker2.no = no;
                    marker2.status = status;
                    map.addOverlay(marker2);
                    //				设置火警图标在上层显示
                    marker.setTop(true);
                    marker.setZIndex(100);
                    //火警光圈向上移动24px
                    $(".humitureNumShow1").show();
                    $(".humitureNumShow2").show();
                    //$(".active-alarm-pointer0").parent().css("top", "-30px");
                } else {
                    pulseHide();
                }
            //}
        });
//    					筛选状态
        $(".humiture-menu-ectopic").on("click", function () {
            $(".humitureNumShow1").show();
            $(".humitureNumShow2").hide();
            showOver();
            pulseShow();
            if (!(status == "humitureAlarm")) {
                map.closeInfoWindow();
//    		            		先隐藏地图上的报警状态图标，再显示
                hideOver();
            } else {

            }
            return false;
        });

        $(".humiture-menu-fault").on("click", function () {
            showOver();
            $(".humitureNumShow2").hide();
            $(".humitureNumShow1").hide();
            if (!(status == "humitureFault")) {
                map.closeInfoWindow();
                hideOver();
                pulseHide();
            } else {
//		              		 
            }
            return false;
        });

        $(".humiture-menu-normal").on("click", function () {
            $(".humitureNumShow1").show();
            $(".humitureNumShow2").show();
            showOver();
            pulseShow();
            return false;
        });

    },//addMarker end

    // 垃圾桶
    trashAddMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {

        // 拼接html字符串
        var sContent = "<div style='margin-top: -20px;'>"
        sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
        sContent += "<div style='padding: 4px;color: #666;min-width: 120px;border-bottom:1px solid #eee;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
        sContent += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
        sContent += ""
        if ((linkMain1 != null) && (linkMain1.length != 0)) {
            sContent += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
        }
        if ((linkMain2 != null) && (linkMain2.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
        }
        if ((linkMain3 != null) && (linkMain3.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
        }
        if ((linkMain4 != null) && (linkMain4.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
        }
        sContent += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td></tr>";
        sContent += "</tbody></table></div></div>";

        // 自定义覆盖物
        function ComplexCustomOverlay(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function (map) {
            this._map = map;
            var div = this._div = document.createElement("div");
            div.className = "active-alarm-pointer";
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            map.getPanes().labelPane.appendChild(div);
            div.parentElement.style.zIndex = div.style.zIndex + 1;//Let ripple be below the icon
            return div;
        }
        ComplexCustomOverlay.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - 40 - 8 + 'px';
            this._div.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay.prototype.getPosition = function () {
            return this._point;
        }

        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
            this._div['on' + event] = fun;
        }
        if (status == 'trashBrimOver') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/ashbin-yellow2.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'trashFault') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/ashbin-grey.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'trashHighTemp') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/ashbin-red.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'trashDump') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/ashbin-purple.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'trashNormal') {
            //摄像头——正常

            var myIcon = new BMap.Icon("map/images/ashbin-blue.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//						设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        }
        else {
            var marker = new BMap.Marker(point);
        }

        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
        var infoWindow = new BMap.InfoWindow(sContent);

        // 创建信息窗口对象
//					 markerNormalmHide()
        //5、 为自定义覆盖物添加点击事件
        marker.addEventListener('click', function () {
            map.openInfoWindow(infoWindow, point);

            //控制信息窗口向上移动
            $(".BMap_pop").parent().css("top", "-24px")
            $(".BMap_shadow").parent().css("top", "-24px")
        });

//				    覆盖物显示
        function showOver() {
            marker.show();
        }

//					覆盖物隐藏
        function hideOver() {
            marker.hide();
        }

//					筛选开关状态
        $(".trash-menu-brimOver").on("click", function () {
            showOver();
            if (!(status == "trashBrimOver")) {
                map.closeInfoWindow();
//		            		先隐藏地图上的报警状态图标，再显示
                hideOver();
            } else {

            }
            return false;
        });

        $(".trash-menu-highTemp").on("click", function () {
            showOver();
            if (!(status == "trashHighTemp")) {
                map.closeInfoWindow();
                hideOver();
            } else {
//		              		 
            }
            return false;
        });
        $(".trash-menu-dump").on("click", function () {
            showOver();
            if (!(status == "trashDump")) {
                map.closeInfoWindow();
                hideOver();
            } else {
//		              		 
            }
            return false;
        });
        $(".trash-menu-fault").on("click", function () {
            showOver();
            if (!(status == "trashFault")) {
                map.closeInfoWindow();
                hideOver();
            } else {
//		              		 
            }
            return false;
        });
        $(".trash-menu-sum").on("click", function () {
            showOver();
            return false;
        });

    },//addMarker end
//-------------------------------------				
    // 路灯
    streetLampAddMarker: function (point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {

        // 拼接html字符串
        var sContent = "<div style='margin-top: -20px;'>"
        sContent += "<h3><div style='display: inline-block;'><strong style='font-size: 16px;'>设备名称: </strong><strong style='font-size: 16px;'>" + deviceName + "</strong></div></h3><hr style='margin-top: 0px;margin-bottom: 0px;'>";
        sContent += "<div style='padding: 4px;color: #666;min-width: 120px;border-bottom:1px solid #eee;'><div><table class='baidumap-tip-table'><tbody><tr><td class='tit' ><i class='fa fa-map-marker'></i>地址：</td><td colspan='2'>" + position + "</td></tr>";
        sContent += "<tr><td class='tit'><i class='fa fa-user-md'></i>联系人:</td><td class='col2-wid'>";
        sContent += ""
        if ((linkMain1 != null) && (linkMain1.length != 0)) {
            sContent += linkMain1 + "</td><td>" + linkPhone1 + "</td> </tr>";
        }
        if ((linkMain2 != null) && (linkMain2.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain2 + "</td><td>" + linkPhone2 + "</td> </tr>";
        }
        if ((linkMain3 != null) && (linkMain3.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain3 + "</td><td>" + linkPhone3 + "</td> </tr>";
        }
        if ((linkMain4 != null) && (linkMain4.length != 0)) {
            sContent += "<tr><td class='tit'></td><td class='col2-wid'>" + linkMain4 + "</td><td>" + linkPhone4 + "</td> </tr>";
        }
        sContent += "<tr><td class='tit'><i class='fa  fa-cube'></i>设备号:</td><td colspan='2'>" + no + "</td></tr>";
        sContent += "</tbody></table></div></div>";

        // 自定义覆盖物
        function ComplexCustomOverlay(point) {
            this._point = point;
            this._no = no;
            this.no = null;
            this._status = status;
            this.status = null;
        }

        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function (map) {
            this._map = map;
            var div = this._div = document.createElement("div");
            div.className = "active-alarm-pointer";
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            map.getPanes().labelPane.appendChild(div);
            div.parentElement.style.zIndex = div.style.zIndex + 1;//Let ripple be below the icon
            return div;
        }
        ComplexCustomOverlay.prototype.draw = function () {
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - 40 - 8 + 'px';
            this._div.style.top = pixel.y - 40 + 10 + 'px';
        }

        ComplexCustomOverlay.prototype.getPosition = function () {
            return this._point;
        }
        //4、自定义覆盖物添加事件方法
        ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
            this._div['on' + event] = fun;
        }
        if (status == 'streetLampOn') {
            //路灯——正常
            sContent += '<tr><td class="tit"></td><td class="col2-wid"><div class="LampBtnPar"><div devCode="' + no + '" deviceName="' + deviceName + '" position="' + position + '" longitude="' + point.lng + '" latitude="' + point.lat + '" status="' + status + '" linkMain1="' + linkMain1 + '" linkMain2="' + linkMain2 + '" linkMain3="' + linkMain3 + '" linkMain4="' + linkMain4 + '"  linkPhone1="' + linkPhone1 + '" linkPhone2="' + linkPhone2 + '" linkPhone3="' + linkPhone3 + '" linkPhone4="' + linkPhone4 + '" id="LampBtn1" class="open1" ><span class="openText">开</span><span class="closeText">关</span><div id="LampBtn2" class="open2"></div></div></div></td></tr>';
//								,{anchor: new BMap.Size(30, 24),infoWindowAnchor: new BMap.Size(30, 20)},offset: new BMap.Size(0, -24)  
            var myIcon = new BMap.Icon("map/images/street light-green.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
//								设置图标在上层显示
            marker.setTop(true);
            marker.setZIndex(100);
        } else if (status == 'streetLampOff') {
            sContent += '<tr><td class="tit"></td><td class="col2-wid"><div id=" class="LampBtnPar"><div devCode="' + no + '" deviceName="' + deviceName + '" position="' + position + '" longitude="' + point.lng + '" latitude="' + point.lat + '" status="' + status + '" linkMain1="' + linkMain1 + '" linkMain2="' + linkMain2 + '" linkMain3="' + linkMain3 + '" linkMain4="' + linkMain4 + '"  linkPhone1="' + linkPhone1 + '" linkPhone2="' + linkPhone2 + '" linkPhone3="' + linkPhone3 + '" linkPhone4="' + linkPhone4 + '" id="LampBtn1" class="close1"><span class="openText">开</span><span class="closeText">关</span><div id="LampBtn2" class="close2"></div></div></div></td></tr>';

            var myIcon = new BMap.Icon("map/images/street light-red.png", new BMap.Size(40, 48));
            var marker = new BMap.Marker(point, {icon: myIcon, offset: new BMap.Size(0, -24)});
            marker.setTop(true);
            marker.setZIndex(100);
        }
        else {
            var marker = new BMap.Marker(point);
        }

        marker.no = no;
        marker.status = status;
        map.addOverlay(marker);
        var infoWindow = new BMap.InfoWindow(sContent);

        // 创建信息窗口对象
//							 markerNormalmHide()
        //5、 为自定义覆盖物添加点击事件
        marker.addEventListener('click', function () {
            map.openInfoWindow(infoWindow, point);
//            单个开灯
            $("body").on("click", "#LampBtn1", lampSwitchFunc());//click(lampSwitchFunc());

            $(".BMap_pop").parent().css("top", "-24px");
            $(".BMap_shadow").parent().css("top", "-24px");
            if (status == 'streetLampOn') {
//							        地图信息框显示
                $('.BMap_pop').parent().show();
                $(".BMap_shadow").parent().show();
            }
        });

//						    覆盖物显示
        function showOver() {
            marker.show();
        }

//							覆盖物隐藏
        function hideOver() {
            marker.hide();
        }

//							筛选开关状态
        $(".streetLampOn").on("click", function () {
            showOver();
            if (!(status == "streetLampOn")) {
                map.closeInfoWindow();
//				            		先隐藏地图上的报警状态图标，再显示
                hideOver();
            } else {

            }
            return false;
        });

        $(".streetLampOff").on("click", function () {
            showOver();
            if (!(status == "streetLampOff")) {
                map.closeInfoWindow();
                hideOver();
            } else {
//				              		 
            }
            return false;
        });
        //灯的全部控制开关

        $(".streetLamp-menu-Sum").click(function () {
            showOver();
        });

    },//addMarker end
    /**
     * 初始化地图
     * mapId 地图div的id
     * longitude 经度
     * latitude 纬度
     * zoom 地图比例大小
     */
    initialize: function (longitude, latitude, zoom) {
        // 百度地图API功能
        var point = BaiDuMap.point(longitude, latitude);
        map.centerAndZoom(point, zoom);
        //map.setZoom(zoom);
        map.enableScrollWheelZoom(true);
        //单击获取点击的经纬度
        map.addEventListener("click", function (e) {
            BaiDuMap.getLongLat(e.point.lng, e.point.lat);
        });
    },
    /**
     * 单个加点
     * longitude 经度
     * latitude 纬度
     * no 编号(唯一)
     * status 不传为默认图标
     */
    addDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4,fireCount) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.addMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4,fireCount);
    },
    cameraAddDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, cameraUrl, loginName, loginPassword) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.cameraAddMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, cameraUrl, loginName, loginPassword);
    },
    streetLampAddDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.streetLampAddMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);
    },
    manholeCoverAddDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.manholeCoverAddMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);
    },
    humitureAddDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, temperatureNum, humidityNum) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.humitureAddMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, temperatureNum, humidityNum);
    },
    trashAddDot: function (longitude, latitude, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4) {
        var point = BaiDuMap.point(longitude, latitude);
        BaiDuMap.trashAddMarker(point, no, deviceName, position, status, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);
    },

//		清除覆盖物
    removeOverlay: function () {
        map.clearOverlays();
    },

    /**
     * 移动地图
     * longitude 经度
     * latitude 纬度
     */
    panTo: function (longitude, latitude) {
        map.panTo(BaiDuMap.point(longitude, latitude));
    },
    /**
     *弹出菜单
     */
    popMenu: function (no) {
        var allOverlay = map.getOverlays();
        for (var i = 0; i < allOverlay.length; i++) {
            if (allOverlay[i].no == no) {
                allOverlay[i].V.click();
                break;
            }
        }

    },

    /**
     * 删除节点
     * no 编号(唯一)
     */
    deletePoint: function (no) {
        var allOverlay = map.getOverlays();
        var arrLength = allOverlay.length;
        for (var i = 0; i < arrLength; i++) {
            if (allOverlay[i].no == no) {
                map.removeOverlay(allOverlay[i]);
            }
        }
    },
  
    deletePointStatus: function (status) {
        var allOverlay = map.getOverlays();
        var arrLength = allOverlay.length;
        for (var i = 0; i < arrLength; i++) {
            if (allOverlay[i].status == status) {
                map.removeOverlay(allOverlay[i]);
            }
        }
    },
    /**
     * 获取点击的经纬度
     */
    getLongLat: function (longitude, latitude) {
        if (clickStatus) {
            winTip.alert("经度:" + longitude + ",纬度:" + latitude);
        }
    },
    /**
     * 允许点击
     */
    openClick: function () {
        clickStatus = true;
    },
    /**
     * 禁止点击
     */
    closeClick: function () {
        clickStatus = false;
    },
    test: function () {
        var myDate = new Date();
        winTip.alert("开始时间:" + myDate.toLocaleTimeString());
        var bounds = map.getBounds();
        var sw = bounds.getSouthWest();
        var ne = bounds.getNorthEast();
        var lngSpan = Math.abs(sw.lng - ne.lng);
        var latSpan = Math.abs(ne.lat - sw.lat);
        for (var i = 0; i < 500; i++) {
            var point1 = new BMap.Point(sw.lng + lngSpan * (Math.random() * 0.7), ne.lat - latSpan * (Math.random() * 0.7));
            BaiDuMap.addMarkerTime(point1, i, '设备' + i, '杭州市', '');
        }
        var myDate1 = new Date();
        winTip.alert("结束时间:" + myDate1.toLocaleTimeString());
    },


};
$(function () {
    /*BaiDuMap.initialize('allmap','120.182701','30.223314',20);*/
    BaiDuMap.map("allmap", {minZoom: 12, maxZoom: 20, enableMapClick: false});
});
